require 'test/unit'

$: << 'aerosol'
require 'aerosol/base/events/events.rb'
require 'aerosol/base/events/input_pad.rb'

class InputPadTest < Test::Unit::TestCase

  def test_create_input_pad
 		input_pad = AS::Event::InputPad.new
		input_pad.key(:fire, :Key_SPACE){|pressed| puts 'lawl'}

    assert_not_nil(input_pad) #it's nice to include an assert, even though we are just checking to make sure this doesn't fail.
  end
  
  def setup_input
  	input_pad = AS::Event::InputPad.new
		input_pad.key(:fire, :Key_SPACE){|pressed| @keyFound = true}
		
		input_pad
  end

  def test_input_pad_hears_events
    @keyFound = false
 		input_pad = setup_input
    
    assert(!@keyFound)

    #now fake the right key.
    event = AS::Event::KeyboardEvent.new(true, AS::Event::KeyboardEvent::Keysyms[:Key_SPACE])
    input_pad.call(event)
    
		assert(@keyFound)
  end

  def test_input_pad_does_not_trigger_on_wrong_events
    @keyFound = false
 		input_pad = setup_input
    
    #now fake push a different key.
    event = AS::Event::KeyboardEvent.new(true, AS::Event::KeyboardEvent::Keysyms[:Key_UP])
    input_pad.call(event)
    
		assert(!@keyFound)
	end
	
end

